package com.lili.collection.core.runner.handler;

import com.lili.collection.core.runner.StageRunner;

import java.util.HashMap;
import java.util.Map;

/**
 * 阶段上下文改变处理器工厂类
 *
 * @author lili
 * @date 2023/3/8 0:00
 */
public class StageContextChangedHandlerFactory {

    private static Map<StageRunner.StageType, StageEventHandler> handlerMap;

    static {
        handlerMap = new HashMap<>();
        handlerMap.put(StageRunner.StageType.Input, new InputContextChangedHandler());
        handlerMap.put(StageRunner.StageType.ProcessGroup, new ProcessGroupContextChangedHandler());
        handlerMap.put(StageRunner.StageType.Output, new OutputContextChangedHandler());
    }

    public static StageEventHandler createHandler(StageRunner.StageType stageType) {
        return handlerMap.get(stageType);
    }
}
